home *** CD-ROM | disk | FTP | other *** search
/ Kit PC World De Ampliacion De Windows 95 / Kit PC World de ampliacion de Windows 95.iso / comunica / hyperter / setup.rul < prev   
Text File  |  1995-12-26  |  17KB  |  502 lines

  1. /*----------------------------------------------------------------------------*\
  2.  *
  3.  *    File Name:  SETUP.RUL
  4.  *
  5.  *  Description:  InstallSHIELD HyperTerminal Setup script.
  6.  *
  7.  *
  8.  *
  9.  *
  10.  *       Author:  Hilgraeve Inc.       Date:  11-8-95
  11.  *
  12.  *
  13.  *
  14. \*----------------------------------------------------------------------------*/
  15.  
  16.  
  17.  
  18. // Size of components.
  19. #define SIZE_REQ_SAMPLES          82000
  20. #define SIZE_REQ_TEMPLATES         2000
  21. #define SIZE_REQ_PROGRAM         482903
  22.  
  23. #define APP_NAME                "HyperTerminal Private Edition"
  24. #define PROGRAM_GROUP_NAME      "HyperTerminal"
  25. #define APPBASE_PATH            "Accessories\\HyperTerminal\\"
  26. #define COMPANY_NAME            "Microsoft"
  27. #define PRODUCT_NAME            "HyperTerminal"
  28. #define PRODUCT_VERSION         "CurrentVersion"
  29. #define PRODUCT_KEY             "HYPERTRM.EXE"
  30. #define UNINSTALL_KEY           "HyperTermPEV1"
  31. #define APPBASE_DIR95        "Program Files"
  32. #define BASE_REGISTRYNT         "Software\\Microsoft\\Windows NT\\CurrentVersion\\App Paths\\"
  33. #define BASE_REGISTRY95         "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\"
  34.  
  35. #define STR_COMPLETE95 "by selecting the program icon in the Programs menu.\n\n"
  36. #define STR_COMPLETENT "by selecting the program icon in the program group.\n\n"
  37.  
  38. declare
  39.  
  40.         // Global variable declarations.
  41.         STRING  svGrp, szMsg, szFileSet, szTitle, szAppPath, szAppSharedDir;
  42.         STRING  szProgram, szTemp, svUninstLogFile, szRegKey, szfile;
  43.         STRING  svMainDirectory[ _MAX_STRING ];
  44.         BOOL    bSpaceOk, bReshowSetupType;
  45.         NUMBER  nResult, nStatusId, nType;
  46.  
  47.         BOOL    bIncludeProgram, bIncludeSamples, bIncludeHelp;
  48.         BOOL    bWinNT;
  49.  
  50.         // Function declarations.
  51.         prototype SetupScreen();
  52.         prototype CheckRequirements();
  53.         prototype CheckSpaceRequirements( number, number, number, string );
  54.         prototype CreateRegDBEntries();
  55.  
  56. program
  57.  
  58. StartHere:
  59.         Disable( BACKGROUND );
  60.  
  61.         // Set up the installation screen.
  62.         SetupScreen();
  63.  
  64.         // Set installation info., which is required for registry entries.
  65.         InstallationInfo( COMPANY_NAME, PRODUCT_NAME, PRODUCT_VERSION, PRODUCT_KEY );
  66.  
  67. // Create a Welcome dialog.
  68. WelcomeDlg:
  69.         Disable( BACKBUTTON );
  70.         Welcome( "Welcome", 0 );
  71.         Enable( BACKBUTTON );
  72.  
  73.         // Test target system proper configuration.
  74.         CheckRequirements();
  75.  
  76.         // Ask user for a destination location for the installation.
  77. GetTargetDirectory:
  78.  
  79.         svMainDirectory = TARGETDISK ^ APPBASE_DIR95 ^ APPBASE_PATH;
  80.  
  81.         szMsg = "NOTE: Choosing to install in the default directory location will overwrite existing HyperTerminal program files.  ";
  82.     szMsg = szMsg + "If you wish to keep your existing program files, select";
  83.     szMsg = szMsg + " a different destination location.";
  84.  
  85.         if ( AskDestPath( "Choose Destination Location", szMsg,
  86.                           svMainDirectory, 0 ) = BACK ) then
  87.            goto WelcomeDlg;
  88.         endif;
  89.  
  90.         szAppSharedDir = svMainDirectory;
  91.  
  92.         nType = TYPICAL;
  93.  
  94. DetermineUserSelection:
  95.  
  96.     bIncludeSamples = TRUE;
  97.     bIncludeProgram = TRUE;
  98.     bIncludeHelp = TRUE;
  99.  
  100.         szMsg = "Select the options you want installed.\n" + 
  101.         "NOTE: Selecting to install pre-defined Connections may " +
  102.         "overwrite your previous connection files with the same file name.";
  103.  
  104.     // Call AskOptions function to display the dialog box.
  105.         if ( AskOptions( NONEXCLUSIVE, szMsg,   
  106.                 "&Application Program Files", bIncludeProgram,
  107.                 "&Pre-defined Connections", bIncludeSamples,
  108.                 "On Line &Help Files", bIncludeHelp) = BACK ) then
  109.         goto GetTargetDirectory;
  110.     endif;
  111.  
  112.         // Check to see if target system meets space requirements.
  113.         bSpaceOk = CheckSpaceRequirements( bIncludeSamples,
  114.                                            bIncludeProgram,
  115.                                            bIncludeHelp,
  116.                                            svMainDirectory );
  117.  
  118.         // Ask user to try again if not enough space available.
  119.         if (bSpaceOk = FALSE) then goto DetermineUserSelection; endif;
  120.  
  121. FolderSelection:
  122.         //if ( bWinNT ) then
  123.         //   svGrp = PROGRAM_GROUP_NAME;
  124.  
  125.            // Allow user to modify folder name.
  126.         //   if ( SelectFolder( "Folder Selection", svGrp, svGrp ) = BACK ) then
  127.         //      goto DetermineUserSelection;
  128.         //   endif;
  129.         //endif;
  130.  
  131.  
  132.  
  133. FileTransferSetup:
  134.  
  135.         // Prepare InstallSHIELD to record deinstallation information.
  136.         DeinstallStart( svMainDirectory, svUninstLogFile, UNINSTALL_KEY, 0 );
  137.         RegDBSetItem( REGDB_UNINSTALL_NAME, APP_NAME );
  138.  
  139.         // Set registry App Paths key information for the main application.
  140.         szAppPath = svMainDirectory  + ";" + szAppSharedDir;
  141.         RegDBSetItem( REGDB_APPPATH, szAppPath );
  142.         szProgram = svMainDirectory ^ "hypertrm.exe";
  143.         RegDBSetItem( REGDB_APPPATH_DEFAULT, szProgram );
  144.  
  145.         // Define the "General" file set.
  146.         szFileSet = "General";
  147.         TARGETDIR = svMainDirectory;
  148.  
  149.         FileSetBeginDefine( szFileSet );
  150.  
  151.           SetStatusWindow( -1, "Copying readme file..." );
  152.  
  153.           // Always copy README & related files, located at
  154.           // the root level in the DATA.Z library file.
  155.           CompressGet( "ht.z", "readme.txt", COMP_NORMAL );
  156.     
  157.     //Delay(1);
  158.  
  159.         SetStatusWindow( 25, "Copying connection files..." );
  160.  
  161.     if (bIncludeSamples) then
  162.              TARGETDIR = svMainDirectory;
  163.              CompressGet( "ht.z", "*.ht", COMP_NORMAL);
  164.     endif;
  165.  
  166.     //Delay(1);
  167.  
  168.           SetStatusWindow( 50, "Copying program files..." );
  169.  
  170.           if (bIncludeProgram) then
  171.              TARGETDIR = szAppSharedDir;
  172.              CompressGet( "ht.z", "*.dll", SHAREDFILE | COMP_UPDATE_DATE );
  173.              CompressGet( "ht.z", "*.exe", SHAREDFILE | COMP_UPDATE_DATE );
  174.           endif;
  175.  
  176.     //Delay(1);
  177.  
  178.         SetStatusWindow( 90, "Copying help..." );
  179.  
  180.     if (bIncludeHelp) then
  181.              TARGETDIR = svMainDirectory;
  182.              CompressGet( "ht.z", "*.hlp", COMP_NORMAL);
  183.     endif;
  184.  
  185.     //Delay(1);    
  186.  
  187.  
  188.         FileSetEndDefine( szFileSet );
  189.  
  190. DoFileTransfer:
  191.         // Set up progress indicator and information gauge.
  192.         Enable( STATUSDLG );
  193.         StatusUpdate( ON, 90 );
  194.  
  195.         // Perform the file set.
  196.         nResult = FileSetPerformEz( szFileSet, 0 );
  197.  
  198.         switch (nResult)
  199.  
  200.         case FS_DONE: // Successful completion.
  201.  
  202.         case FS_CREATEDIR: // Create directory error.
  203.              MessageBox( "Unable to create a directory under " + TARGETDIR + "."+
  204.                          "Please check write access to this directory.", SEVERE );
  205.              abort;
  206.  
  207.         default: // Group all other errors under default label.
  208.              NumToStr( szTemp, nResult );
  209.              MessageBox( "General file transfer error."+
  210.                           "Please check your target location and try again."+
  211.                           "\n\n Error Number:"+szTemp, SEVERE );
  212.  
  213.              abort;
  214.         endswitch;
  215.  
  216.     szfile = svMainDirectory ^ "*.dll";
  217.     SetFileInfo( szfile , FILE_ATTRIBUTE, FILE_ATTR_HIDDEN , "" );
  218.     TARGETDIR = svMainDirectory;
  219.     DeleteFile( "DeIsLog.*" );
  220.  
  221.  
  222. SetRegistryEntries:
  223.  
  224.         CreateRegDBEntries( );
  225.  
  226.         Delay(2);
  227.         Disable( FEEDBACK_FULL );
  228.         Disable( STATUSDLG );
  229.  
  230.         // Create program groups (folders) and icons.
  231.  
  232. CreateFolderIcons:
  233.         SetStatusWindow( 95, "Creating Folder and Icons...." );
  234.  
  235.         LongPathToShortPath( svMainDirectory );
  236.  
  237.  
  238.  
  239.     // Create shortcut to HyperTerminal directory
  240.     AddFolderIcon( "Accessories" , "HyperTerminal" , 
  241.                 svMainDirectory , 
  242.                 "" , "" , 0 , "" ,
  243.                 REPLACE );
  244.  
  245.         // Announce setup complete and offer to read README file.
  246.         SetStatusWindow( 100, "Installation complete." );
  247.  
  248.         // If shared files could not be installed, then users must restart system.
  249.         if (BATCH_INSTALL = TRUE) then
  250.            szMsg = "Some files could not be installed because they are "+
  251.                    "currently in use by other programs in the system.  "+
  252.                    "To allow for proper operation of the new program you should restart "+
  253.                    "your system at this time.";
  254.            CommitSharedFiles(0);
  255.            RebootDialog( "Restart Windows", szMsg, SYS_BOOTMACHINE );
  256.         else
  257.        ShowProgramFolder(svMainDirectory, SW_RESTORE);
  258.            szMsg = "Setup is complete.  You may run the installed program ";
  259.            if ( bWinNT ) then
  260.               szMsg = szMsg + STR_COMPLETENT;
  261.            else
  262.               szMsg = szMsg + STR_COMPLETE95;
  263.            endif;
  264.  
  265.            MessageBeep( 0 );
  266.            MessageBox( szMsg, INFORMATION );
  267.         endif;
  268.  
  269.         exit;
  270.  
  271.  
  272. /*---------------------------------------------------------------------------*\
  273.  *
  274.  * Function:  SetupScreen
  275.  *
  276.  *  Purpose:  This function will set up the screen look.  This includes
  277.  *            colors, fonts, text to be displayed, etc.
  278.  *
  279.  *
  280.  *    Input:
  281.  *
  282.  *  Returns:
  283.  *
  284.  * Comments:
  285. \*---------------------------------------------------------------------------*/
  286.  
  287. function SetupScreen()
  288.         begin
  289.  
  290.           Enable( INDVFILESTATUS );
  291.  
  292.           SetTitle( APP_NAME + " Setup", 28, WHITE );
  293.  
  294.           SetTitle( "Setup", 0, BACKGROUNDCAPTION ); // Caption bar text.
  295.  
  296.           Enable( BACKGROUND );
  297.  
  298.         end;
  299.  
  300.  
  301. /*---------------------------------------------------------------------------*\
  302.  *
  303.  * Function:  CheckRequirements
  304.  *
  305.  *  Purpose:  This function will check all minimum requirements for the
  306.  *            application being installed.  If any fail, then the user
  307.  *            is informed and the installation is terminated.
  308.  *
  309.  *
  310.  *    Input:
  311.  *
  312.  *  Returns:
  313.  *
  314.  * Comments:
  315. \*---------------------------------------------------------------------------*/
  316.  
  317. function CheckRequirements()
  318.           number  nvDx, nvDy;
  319.           number nvResult;
  320.           STRING szResult;
  321.         begin
  322.  
  323.           // Determine if target system uses NT or Windows 95.
  324.           GetSystemInfo( WINMAJOR, nvResult, szResult );
  325.           bWinNT = TRUE;
  326.           if (nvResult = 4) then
  327.              bWinNT = FALSE; // Running Windows 95.
  328.           endif;
  329.  
  330.           // Check screen resolution.
  331.           GetExtents( nvDx, nvDy );
  332.           if (nvDy < 480) then
  333.              MessageBox( "This program requires VGA or better resolution.", WARNING );
  334.              exit;
  335.           endif;
  336.  
  337.         end;
  338.  
  339. /*---------------------------------------------------------------------------*\
  340.  *
  341.  * Function:  CheckSpaceRequirements
  342.  *
  343.  *  Purpose:  This function will check space requirements based on the
  344.  *            elements being installed.
  345.  *
  346.  *    Input:
  347.  *
  348.  *  Returns:
  349.  *
  350.  * Comments:
  351. \*---------------------------------------------------------------------------*/
  352.  
  353. function CheckSpaceRequirements( bIncludeSamples,
  354.                                  bIncludeProgram,
  355.                                  bIncludeHelp,
  356.                                  szDir )
  357.           number  nSizeRequired;
  358.         begin
  359.  
  360.           nSizeRequired = 0;
  361.  
  362.           // Determine total size.
  363.           if (bIncludeSamples) then
  364.             nSizeRequired = nSizeRequired + SIZE_REQ_SAMPLES;
  365.           endif;
  366.  
  367.           if (bIncludeHelp) then
  368.             nSizeRequired = nSizeRequired + SIZE_REQ_TEMPLATES;
  369.           endif;
  370.  
  371.           if (bIncludeProgram) then
  372.             nSizeRequired = nSizeRequired + SIZE_REQ_PROGRAM;
  373.           endif;
  374.  
  375.           // Check space on target drive.
  376.           bSpaceOk = TRUE;
  377.           if (GetDiskSpace( szDir ) < nSizeRequired) then
  378.              szMsg = "There is not enough space available on the disk\n" +
  379.                      "'" + svMainDirectory + "' \n" +
  380.                      "Please free up some space or change the target location\n" +
  381.                      "to a different disk";
  382.              MessageBeep(0);
  383.              MessageBox( szMsg, WARNING );
  384.              bSpaceOk = FALSE;
  385.           endif;
  386.  
  387.           return bSpaceOk;
  388.         end;
  389.  
  390.  
  391. /*---------------------------------------------------------------------------*\
  392.  *
  393.  * Function:  CreateRegDBEntries
  394.  *
  395.  *  Purpose:  This function will create necessary keys and values for
  396.  *            the sample program.
  397.  *
  398.  *    Input:
  399.  *
  400.  *  Returns:
  401.  *
  402.  * Comments:
  403. \*---------------------------------------------------------------------------*/
  404.  
  405. function CreateRegDBEntries()
  406.         string szKey[255], szClass[255], szValue, szDemo, szProgram;
  407.  
  408. begin
  409.  
  410.     // Set root registry level
  411.         RegDBSetDefaultRoot( HKEY_LOCAL_MACHINE );
  412.  
  413.         // Create App Path entry
  414.         szKey = BASE_REGISTRY95 + "\\" + PRODUCT_KEY;
  415.     szClass = svMainDirectory ^ PRODUCT_KEY;
  416.         RegDBCreateKeyEx( szKey, szClass );
  417.         RegDBSetKeyValueEx( szKey, "Path", REGDB_STRING, svMainDirectory, -1 );
  418.  
  419.         // Create .ht class.
  420.         szKey = "\\SOFTWARE\\Classes\\.ht";
  421.     RegDBCreateKeyEx( szKey, "" ); 
  422.         RegDBSetKeyValueEx( szKey, "", REGDB_STRING, "htfile", -1 );
  423.  
  424.         // Create htfile class.
  425.         szKey = "\\SOFTWARE\\Classes\\htfile";
  426.     RegDBCreateKeyEx( szKey, "" );
  427.         RegDBSetKeyValueEx( szKey, "", REGDB_STRING, "HyperTerminal File", -1 );
  428.  
  429.         // Create htfile\defaulticon class.
  430.         szKey = "\\SOFTWARE\\Classes\\htfile\\DefaultIcon";
  431.     RegDBCreateKeyEx( szKey, "" );
  432.         RegDBSetKeyValueEx( szKey, "", REGDB_STRING, "%1", -1 );
  433.  
  434.         // Create htfile\defaulticon\shell class.
  435.         szKey = "\\SOFTWARE\\Classes\\htfile\\shell";
  436.     RegDBCreateKeyEx( szKey, "" );
  437.         RegDBSetKeyValueEx( szKey, "", REGDB_STRING, "connect", -1 );
  438.  
  439.         // Create htfile\defaulticon\shell\connect class.
  440.         szKey = "\\SOFTWARE\\Classes\\htfile\\shell\\connect";
  441.     RegDBCreateKeyEx( szKey, "" );
  442.         RegDBSetKeyValueEx( szKey, "", REGDB_STRING, "&Connect", -1 );
  443.  
  444.         // Create htfile\defaulticon\shell\connect\command class.
  445.         szKey = "\\SOFTWARE\\Classes\\htfile\\shell\\connect\\command";
  446.     RegDBCreateKeyEx( szKey, "" );
  447.         RegDBSetKeyValueEx( szKey, "", REGDB_STRING, svMainDirectory ^ "hypertrm.exe /d %1", -1 );
  448.  
  449.         // Create htfile\defaulticon\shell\open class.
  450.         szKey = "\\SOFTWARE\\Classes\\htfile\\shell\\open";
  451.     RegDBCreateKeyEx( szKey, "" );
  452.  
  453.         // Create htfile\defaulticon\shell\open\command class.
  454.         szKey = "\\SOFTWARE\\Classes\\htfile\\shell\\open\\command";
  455.     RegDBCreateKeyEx( szKey, "" );
  456.         RegDBSetKeyValueEx( szKey, "", REGDB_STRING, svMainDirectory ^ "hypertrm.exe %1", -1 );
  457.  
  458.         // Create htfile\shellex class.
  459.         szKey = "\\SOFTWARE\\Classes\\htfile\\shellex";
  460.     RegDBCreateKeyEx( szKey, "" );
  461.  
  462.         // Create htfile\shellex\IconHandler class.
  463.         szKey = "\\SOFTWARE\\Classes\\htfile\\shellex\\IconHandler";
  464.     RegDBCreateKeyEx( szKey, "" );
  465.         RegDBSetKeyValueEx( szKey, "", REGDB_STRING, "{88895560-9AA2-1069-930E-00AA0030EBC8}", -1 );
  466.  
  467.         // Create htfile\shellex\PropertySheetHandlers class.
  468.         szKey = "\\SOFTWARE\\Classes\\htfile\\shellex\PropertySheetHandlers";
  469.     RegDBCreateKeyEx( szKey, "" );
  470.  
  471.         // Create htfile\shellex\PropertySheetHandlers\TermPage class.
  472.         szKey = "\\SOFTWARE\\Classes\\htfile\\shellex\\PropertySheetHandlers\\TermPage";
  473.     RegDBCreateKeyEx( szKey, "" );
  474.         RegDBSetKeyValueEx( szKey, "", REGDB_STRING, "{1B53F360-9A1B-1069-930C-00AA0030EBC8}", -1 );
  475.  
  476.         // Create CLSID\... classes.
  477.  
  478.     // for Page handler
  479.         szKey = "\\SOFTWARE\\Classes\\CLSID";
  480.     szKey = szKey + "\\{1B53F360-9A1B-1069-930C-00AA0030EBC8}";
  481.     RegDBCreateKeyEx( szKey , "" ); 
  482.         RegDBSetKeyValueEx( szKey, "", REGDB_STRING, "HyperTerminal Connection Page Ext", -1 );
  483.  
  484.     szKey = szKey + "\\InProcServer32";
  485.     RegDBCreateKeyEx( szKey , "" ); 
  486.         RegDBSetKeyValueEx( szKey, "", REGDB_STRING, svMainDirectory ^ "hypertrm.dll", -1 );
  487.         RegDBSetKeyValueEx( szKey, "ThreadingModel", REGDB_STRING, "Apartment", -1 );
  488.  
  489.     // for Icon Handler
  490.         szKey = "\\SOFTWARE\\Classes\\CLSID";
  491.     szKey = szKey + "\\{88895560-9AA2-1069-930E-00AA0030EBC8}";
  492.     RegDBCreateKeyEx( szKey , "" ); 
  493.         RegDBSetKeyValueEx( szKey, "", REGDB_STRING, "HyperTerminal Icon Ext", -1 );
  494.  
  495.     szKey = szKey + "\\InProcServer32";
  496.     RegDBCreateKeyEx( szKey , "" ); 
  497.         RegDBSetKeyValueEx( szKey, "", REGDB_STRING, svMainDirectory ^ "hticons.dll", -1 );
  498.         RegDBSetKeyValueEx( szKey, "ThreadingModel", REGDB_STRING, "Apartment", -1 );
  499.  
  500. end;
  501.  
  502.